﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Korbit.Common
{
    class CommonFunction
    {
        public static string ConvertURLParameter(Dictionary<string, string> dicParameter)
        {
            string strReturn = "";
            string strKey;
            string strValue;

            foreach (KeyValuePair<String, String> key in dicParameter)
            {
                //key와 value
                strKey = key.Key;
                strValue = key.Value;

                //URL Encoding
                strKey = HttpUtility.UrlEncode(strKey);
                strValue = HttpUtility.UrlEncode(strValue);

                if (strReturn.Length == 0)
                {
                    strReturn = strKey + "=" + strValue;
                }
                else
                {
                    strReturn = strReturn + "&" + strKey + "=" + strValue;
                }

            }

            return strReturn;
        }

        public static bool IsNumeric(String strValue)
        {
            decimal d;

            if (strValue.Length == 0)
                return false;

            return Decimal.TryParse(strValue, out d);
        }
    }
}
